﻿using System;
using System.Data;
using Model.Data;
using Model;
using DataAccess;
using BusinessLogic.BusinessRules;


namespace BusinessLogic.ClassFactory
{
    /// <summary>
    /// WebSiteFactory 的摘要说明。
    /// </summary>
    public class WebSiteFactory : BaseFactory
    {
        public WebSiteFactory()
            : base()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        public WebSiteFactory(DBManager l_DBManager)
            : base(l_DBManager)
        {
        }
        public WebSite NewInstance()
        {
            WebSiteAccess l_Access = new WebSiteAccess(m_Manager);
            WebSite objWebSite = new WebSite(this.m_Manager, l_Access);
            objWebSite.NewDataSet();
            objWebSite.SelectRow(0);
            return objWebSite;
        }

        public WebSite CreatorBySql(string Sql)
        {
            WebSiteAccess l_Access = new WebSiteAccess(m_Manager);
            WebSite objWebSite = new WebSite(this.m_Manager, l_Access);
            DataSet l_ds = new WebSiteData();
            if (l_Access.QueryBySql(ref l_ds, Sql) < 1)
            {
                return null;
            }
            objWebSite.SetDataSet(l_ds);
            objWebSite.SelectRow(0);
            return objWebSite;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="intWebSiteID"></param>
        /// <returns></returns>
        public WebSite Creator(int intWebSiteID)
        {
            WebSiteAccess l_Access = new WebSiteAccess(m_Manager);
            WebSite objWebSite = new WebSite(this.m_Manager, l_Access);
            DataSet l_ds = new WebSiteData();
            if (l_Access.QueryByID(ref l_ds, intWebSiteID) < 1)
            {
                return null;
            }
            objWebSite.SetDataSet(l_ds);
            objWebSite.SelectRow(0);
            return objWebSite;
        }

        public WebSite Creator()
        {
            WebSiteAccess l_Access = new WebSiteAccess(m_Manager);
            WebSite objWebSite = new WebSite(this.m_Manager, l_Access);
            DataSet l_ds = new WebSiteData();
            if (l_Access.QueryAll(ref l_ds) < 1)
            {
                return null;

            }
            objWebSite.SetDataSet(l_ds);
            objWebSite.SelectRow(0);
            return objWebSite;
        }

    }
}
